home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1432.dms / var1432.adf / NDUK-V40.lha / V40 / include / libraries / realtime.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  8KB  |  225 lines

  1. #ifndef LIBRARIES_REALTIME_H
  2. #define LIBRARIES_REALTIME_H
  3. /*
  4. **    $VER: realtime.h 40.3 (5.4.93)
  5. **    Includes Release 40.15
  6. **
  7. **    realtime.library timing and syncing system
  8. **
  9. **    (C) Copyright 1993 Commodore-Amiga Inc.
  10. **    All Rights Reserved
  11. */
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16. #ifndef EXEC_TYPES_H
  17. #include <exec/types.h>
  18. #endif
  19.  
  20. #ifndef EXEC_LISTS_H
  21. #include <exec/lists.h>
  22. #endif
  23.  
  24. #ifndef EXEC_LIBRARIES_H
  25. #include <exec/libraries.h>
  26. #endif
  27.  
  28. #ifndef UTILITY_TAGITEM_H
  29. #include <utility/tagitem.h>
  30. #endif
  31.  
  32. #ifndef UTILITY_HOOKS_H
  33. #include <utility/hooks.h>
  34. #endif
  35.  
  36.  
  37. /*****************************************************************************/
  38.  
  39.  
  40. /* realtime.library's idea of time is based on a clock which emits a pulse
  41.  * 1200 times a second (1.2kHz). All time values maintained by realtime.library
  42.  * are based on this number. For example, the field RealTimeBase->rtb_Time
  43.  * expresses an amount of time equivalent to (RealTimeBase->rtb_Time/TICK_FREQ)
  44.  * seconds.
  45.  */
  46. #define TICK_FREQ 1200
  47.  
  48.  
  49. /*****************************************************************************/
  50.  
  51.  
  52. /* Each Conductor represents a group of applications which wish to remain
  53.  * synchronized together.
  54.  *
  55.  * This structure must only be allocated by realtime.library and is
  56.  * READ-ONLY!
  57.  */
  58. struct Conductor
  59. {
  60.     struct Node    cdt_Link;
  61.     UWORD       cdt_Reserved0;
  62.     struct MinList cdt_Players;         /* this conductor's players      */
  63.     ULONG       cdt_ClockTime;     /* current time of this sequence */
  64.     ULONG       cdt_StartTime;     /* start time of this sequence   */
  65.     ULONG       cdt_ExternalTime;     /* time from external unit      */
  66.     ULONG       cdt_MaxExternalTime;  /* upper limit on sync'd time      */
  67.     ULONG       cdt_Metronome;     /* MetricTime highest pri node   */
  68.     UWORD       cdt_Reserved1;
  69.     UWORD       cdt_Flags;         /* conductor flags          */
  70.     UBYTE       cdt_State;         /* playing or stopped          */
  71. };
  72.  
  73. /* Flag bits for Conductor.cdt_Flags */
  74. #define CONDUCTF_EXTERNAL (1<<0)   /* clock is externally driven */
  75. #define CONDUCTF_GOTTICK  (1<<1)   /* received 1st external tick */
  76. #define CONDUCTF_METROSET (1<<2)   /* cdt_Metronome filled in     */
  77. #define CONDUCTF_PRIVATE  (1<<3)   /* conductor is private     */
  78.  
  79. #define CONDUCTB_EXTERNAL 0
  80. #define CONDUCTB_GOTTICK  1
  81. #define CONDUCTB_METROSET 2
  82. #define CONDUCTB_PRIVATE  3
  83.  
  84. /* constants for Conductor.cdt_State and SetConductorState() */
  85. #define CONDSTATE_STOPPED     0      /* clock is stopped           */
  86. #define CONDSTATE_PAUSED      1      /* clock is paused           */
  87. #define CONDSTATE_LOCATE      2      /* go to 'running' when ready    */
  88. #define CONDSTATE_RUNNING     3      /* run clock NOW           */
  89.  
  90. /* These do not actually exist as Conductor states, but are used as additional
  91.  * arguments to SetConductorState()
  92.  */
  93. #define CONDSTATE_METRIC     -1      /* ask high node to locate       */
  94. #define CONDSTATE_SHUTTLE    -2      /* time changing but not running */
  95. #define CONDSTATE_LOCATE_SET -3      /* maestro done locating       */
  96.  
  97.  
  98. /*****************************************************************************/
  99.  
  100.  
  101. /* The Player is the connection between a Conductor and an application.
  102.  *
  103.  * This structure must only be allocated by realtime.library and is
  104.  * READ-ONLY!
  105.  */
  106. struct Player
  107. {
  108.     struct Node       pl_Link;
  109.     BYTE          pl_Reserved0;
  110.     BYTE          pl_Reserved1;
  111.     struct Hook      *pl_Hook;         /* player's hook function     */
  112.     struct Conductor *pl_Source;     /* pointer to parent context     */
  113.     struct Task      *pl_Task;         /* task to signal for alarm     */
  114.     LONG          pl_MetricTime;     /* current time in app's metric */
  115.     LONG          pl_AlarmTime;     /* time to wake up         */
  116.     void         *pl_UserData;     /* for application use     */
  117.     UWORD          pl_PlayerID;     /* for application use     */
  118.     UWORD          pl_Flags;     /* general Player flags     */
  119. };
  120.  
  121. /* Flag bits for Player.pl_Flags */
  122. #define PLAYERF_READY      (1<<0)   /* player is ready to go!        */
  123. #define PLAYERF_ALARMSET  (1<<1)   /* alarm is set            */
  124. #define PLAYERF_QUIET      (1<<2)   /* a dummy player, used for sync */
  125. #define PLAYERF_CONDUCTED (1<<3)   /* give me metered time        */
  126. #define PLAYERF_EXTSYNC   (1<<4)   /* granted external sync        */
  127.  
  128. #define PLAYERB_READY      0
  129. #define PLAYERB_ALARMSET  1
  130. #define PLAYERB_QUIET      2
  131. #define PLAYERB_CONDUCTED 3
  132. #define PLAYERB_EXTSYNC   4
  133.  
  134.  
  135. /*****************************************************************************/
  136.  
  137.  
  138. /* Tags for CreatePlayer(), SetPlayerAttrs(), and GetPlayerAttrs() */
  139. #define PLAYER_Base        (TAG_USER+64)
  140. #define PLAYER_Hook        (PLAYER_Base+1)   /* set address of hook function */
  141. #define PLAYER_Name        (PLAYER_Base+2)   /* name of player          */
  142. #define PLAYER_Priority     (PLAYER_Base+3)   /* priority of player          */
  143. #define PLAYER_Conductor    (PLAYER_Base+4)   /* set conductor for player     */
  144. #define PLAYER_Ready        (PLAYER_Base+5)   /* the "ready" flag          */
  145. #define PLAYER_AlarmTime    (PLAYER_Base+12)  /* alarm time (sets PLAYERF_ALARMSET) */
  146. #define PLAYER_Alarm        (PLAYER_Base+13)  /* sets/clears PLAYERF_ALARMSET flag  */
  147. #define PLAYER_AlarmSigTask (PLAYER_Base+6)   /* task to signal for alarm/notify    */
  148. #define PLAYER_AlarmSigBit  (PLAYER_Base+8)   /* signal bit for alarm (or -1) */
  149. #define PLAYER_Conducted    (PLAYER_Base+7)   /* sets/clears PLAYERF_CONDUCTED flag   */
  150. #define PLAYER_Quiet        (PLAYER_Base+9)   /* don't process time thru this */
  151. #define PLAYER_UserData     (PLAYER_Base+10)
  152. #define PLAYER_ID        (PLAYER_Base+11)
  153. #define PLAYER_ExtSync        (PLAYER_Base+14)  /* attempt/release to ext sync  */
  154. #define PLAYER_ErrorCode    (PLAYER_Base+15)  /* error return value          */
  155.  
  156.  
  157. /*****************************************************************************/
  158.  
  159.  
  160. /* Method types for messages sent via a Player's hook */
  161. #define PM_TICK     0
  162. #define PM_STATE    1
  163. #define PM_POSITION 2
  164. #define PM_SHUTTLE  3
  165.  
  166. /* used for PM_TICK, PM_POSITION and PM_SHUTTLE methods */
  167. struct pmTime
  168. {
  169.     ULONG pmt_Method;         /* PM_TICK, PM_POSITION, or PM_SHUTTLE */
  170.     ULONG pmt_Time;
  171. };
  172.  
  173. /* used for the PM_STATE method */
  174. struct pmState
  175. {
  176.     ULONG pms_Method;         /* PM_STATE */
  177.     ULONG pms_OldState;
  178. };
  179.  
  180.  
  181. /*****************************************************************************/
  182.  
  183.  
  184. /* Possible lock types for LockRealTime() */
  185. #define RT_CONDUCTORS 0   /* conductor list */
  186.  
  187.  
  188. /*****************************************************************************/
  189.  
  190.  
  191. /* realtime.library error codes */
  192. #define RTE_NOMEMORY    801   /* memory allocation failed      */
  193. #define RTE_NOCONDUCTOR 802   /* player needs a conductor      */
  194. #define RTE_NOTIMER    803   /* timer (CIA) allocation failed */
  195. #define RTE_PLAYING    804   /* can't shuttle while playing   */
  196.  
  197.  
  198. /*****************************************************************************/
  199.  
  200.  
  201. /* OpenLibrary("realtime.library",0) returns a pointer to this structure.
  202.  * All fields are READ-ONLY.
  203.  */
  204. struct RealTimeBase
  205. {
  206.     struct Library rtb_LibNode;
  207.     UBYTE       rtb_Reserved0[2];
  208.  
  209.     ULONG       rtb_Time;         /* current time                 */
  210.     ULONG       rtb_TimeFrac;     /* fixed-point fraction part of time    */
  211.     UWORD       rtb_Reserved1;
  212.     WORD       rtb_TickErr;      /* nanosecond error from ideal Tick     */
  213. };                     /* length to real tick length         */
  214.  
  215. /* Actual tick length is: 1/TICK_FREQ + rtb_TickErr/1e9 */
  216.  
  217. #define RealTime_TickErr_Min -705
  218. #define RealTime_TickErr_Max  705
  219.  
  220.  
  221. /*****************************************************************************/
  222.  
  223.  
  224. #endif /* LIBRARIES_REALTIME_H */
  225.